<?php
// 获取资源

include '../init.php';

$imageid = @$_GET['imageid'];
if (empty($imageid)){
	$realpath = UPLOAD_DIR.'avatar.jpeg';
	header('Content-type:image/png');
	readfile($realpath);
	return;
}

make_avatar($imageid);

function make_avatar($imageid){
	$arr = array();
	$sql = "SELECT fid,fpath,name FROM `uploadfile_tb` WHERE fid=".$imageid." LIMIT 1 ;";
	if (!my_mysql_query($sql, $arr)) {
		var_dump('图片加载失败');
		exit();
	}
	
	$realpath = UPLOAD_DIR.$arr[0]['fpath'];
	// var_dump($realpath);
	header('Content-type:image/png');
	readfile($realpath);
}